<?php
if(isset($_GET['id']))
{
	require_once "php/page/_page-detail.php";
	return;
}
?>	
<div class='s_block' id='left'>
	<div class='sub_header'>Tin mới nhất</div>						
	<div class='content'>
		<?php
		$max_id=PHP_INT_MAX;
		$min_id=0;
		$table=Db::mysql_query(" SELECT * FROM tbl_page WHERE page_group_id=3 AND page_status=1 AND page_focus=0 ORDER BY page_id DESC LIMIT ".Common::fetch_record_start(ROW_PER_PAGE_TIN_TUC).",".ROW_PER_PAGE_TIN_TUC,FETCH_MODE_TABLE);
		foreach ($table as $key=>$row)
		{
			
			$link="index.php?page=tin-tuc&alias=".$row['page_alias']."&id=".$row['page_id'];
		?>
			<div class='x_block'>
				<a href='<?php echo $link?>' class='image'><img src='<?php echo Common::get_thumb_path($row['page_image']);?>' class='i-update' link='page=_page-delete&id=<?php echo $row['page_id'];?>' confirm='1' popup='0' label='Xóa tin' /></a>
				<a href='<?php echo $link?>' class='title'><?php echo $row['page_title']?></a>
				<div class='content'>
					<span class='i-update' link='page=_page-update&id=<?php echo $row['page_id'];?>'><?php echo $row['page_quote']?></span>
					<a href='<?php echo $link?>' class='read_more title'>Xem chi tiết</a>
				</div>	
			</div>
			<?php
			if($key==0)
				$max_id=$row['page_id'];
			if($key==count($table)-1)
				$min_id=$row['page_id'];
			if($key<count($table)-1){?>
			<div class='clear'></div>
			<?php }?> 	
		<?php 
		}
		?>
		<div class="clear"></div>
		<div class="border_top">
			<?php Partial::paginator('index.php?page=tin-tuc',ROW_PER_PAGE_TIN_TUC,"SELECT COUNT(*) FROM tbl_page WHERE page_group_id=3 AND page_status=1 AND page_focus=0");		?>
		</div>				
	</div>
</div>
<div class='s_block m_block' id='right'>
	<div class='sub_header'>Tin nổi bật</div>
	<?php 
	$row=Db::mysql_query(" SELECT * FROM tbl_page WHERE page_group_id=3 AND page_focus=1",FETCH_MODE_ROW);
	if($row)
	{
		$link="index.php?page=tin-tuc&alias=".$row['page_alias']."&id=".$row['page_id'];
		?>
		<a class='image' href='<?php echo $link?>'><img src='<?php echo Common::get_thumb_path($row['page_image']);?>' class='i-update' link='page=_page-delete&id=<?php echo $row['page_id'];?>' confirm='1' popup='0' label='Xóa tin'/></a>
		<a class='title' href='<?php echo $link?>'><?php echo $row['page_title']?></a>
		<div class='content'>
			<span class='i-update' link='page=_page-update&id=<?php echo $row['page_id'];?>'><?php echo $row['page_quote']?></span>
			<br/><a href='<?php echo $link?>' class='read_more title'>Xem chi tiết</a>
		</div>	
	<?php 
	}
	else
		echo LUPDATING;
	?>
</div>
<div class="s_block h_line" id='right'></div>
<div class='s_block' id='right'>
	<div class='sub_header'>Các tin khác</div>		
	<div class='content'>
		<div class='y_block' >							
			<div class='content'>
				<ul id='left' style='margin-top:0px'>
				<?php
				$table=Db::mysql_query(" SELECT * FROM tbl_page WHERE page_group_id=3 AND page_status=1 AND page_focus=0 AND (page_id>$max_id OR page_id<$min_id) ORDER BY RAND() LIMIT 12 ",FETCH_MODE_TABLE);
				foreach ($table as $key=>$row)
				{
					if($key==ceil(count($table)/2))
					{
					?>
					</ul>
					<ul id='right' style='margin-top:0px'>
					<?php
					} 
					?>
					<li><a href="index.php?page=tin-tuc&alias=<?php echo $row['page_alias'];?>&id=<?php echo $row['page_id'];?>"><?php echo $row['page_title'];?></a></li>
					<?php
				} 
				?>		
				</ul>							
			</div>											
		</div>
	</div>
</div>